package com.soft.sitegenerator.form;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import org.apache.struts.action.ActionForm;

import com.soft.sitegenerator.Component;
import com.soft.sitegenerator.DataBaseComponent;
import com.soft.sitegenerator.business.hibernate.Person;

public class PersonEditForm extends ActionForm {

	private static final long serialVersionUID = 1L;

	private Component component = new DataBaseComponent();
	private Person person = (Person) component.getBean("personsHib");
	private String fecha ;
	private SimpleDateFormat formatoDelTexto = new SimpleDateFormat("dd/MM/yyyy");

	public Person getPerson() {
		return this.person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	public boolean equals(Object arg0) {
		return person.equals(arg0);
	}

	public Date getBornDate() {
		return person.getBornDate();
	}

	public void setBornDate(Date d) {
		this.person.setBornDate(d);
	}

	public String getMail() {
		return person.getMail();
	}

	public void setMail(String email) {
		person.setMail(email);
	}

	public Long getId() {
		return person.getId();
	}

	public void setId(Long id) {
		person.setId(id);
	}

	public String getName() {
		return person.getName();
	}

	public void setName(String name) {
		person.setName(name);
	}

	public String getSurname() {
		return person.getSurname();
	}

	public void setSurname(String surname) {
		person.setSurname(surname);
	}

	public String getAddress() {
		return person.getAddress();
	}

	public void setAddress(String address) {
		person.setAddress(address);
	}

	public String getCity() {
		return person.getCity();
	}

	public void setCity(String city) {

		person.setCity(city);
	}

	public String getPostalCode() {
		return person.getPostalCode();
	}

	public void setPostalCode(String postalcode) {
		person.setPostalCode(postalcode);
	}

	public String getState() {
		return person.getState();
	}

	public void setState(String state) {
		person.setState(state);
	}

	public String getCountry() {
		return person.getCountry();
	}

	public void setCountry(String country) {
		person.setCountry(country);
	}

	public String getPhoneNumber() {
		return person.getPhoneNumber();
	}

	public void setPhoneNumber(String phoneNumber) {
		person.setPhoneNumber(phoneNumber);
	}

	public Long getUserId() {
		return person.getUser().getId();
	}

	public void setUserId(Long userId) {
		this.setUserId(userId);
	}

	public String getFecha() {
		if (this.getBornDate()!=null)
		return (formatoDelTexto.format(this.getBornDate()));
		else  return("");
	}

	public void setFecha(String strFecha) {
		Date fecha = null;
		try {
			fecha = formatoDelTexto.parse(strFecha);
		} catch (ParseException ex) {
			ex.printStackTrace();
		}
		this.person.setBornDate(fecha);
		}
}